package com.qkbb.admin.kuibu.wxapi;

import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import com.qkbb.admin.kuibu.R;
import com.tencent.mm.sdk.modelbase.BaseReq;
import com.tencent.mm.sdk.modelbase.BaseResp;
import com.tencent.mm.sdk.modelmsg.SendAuth;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.sdk.openapi.WXAPIFactory;

public class WXEntryActivity extends Activity implements IWXAPIEventHandler{
    private IWXAPI api;
    public static SendAuth.Resp resp;
    private static final String APP_ID="wx7a4daf296830c97d";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wxentry);
        api = WXAPIFactory.createWXAPI(this,APP_ID , false);
        api.handleIntent(getIntent(), this);
    }

    @Override
    public void onReq(BaseReq baseReq) {
        Log.e("111",baseReq.openId);

    }

    @Override
    public void onResp(BaseResp baseResp) {
        String result = "";
        if (baseResp.errCode==BaseResp.ErrCode.ERR_OK){
            resp=((SendAuth.Resp) baseResp);
            Toast.makeText(this,"登录成功",Toast.LENGTH_SHORT).show();
            }else {
            Toast.makeText(this,"登录失败",Toast.LENGTH_SHORT).show();
        }
        finish();
    }

}
